#------------
# User admin
+@app.route('/users/admin/list')
+def admin_users():
+ if not session.get('user').get('is_admin'):
+ abort(401)
+ users = query_db('select * from users order by id desc')
+ return render_template('admin_users.html', users=users)
+
@app.route('/users/admin/add', methods=['GET', 'POST'])
def add_user():
if not session.get('user').get('is_admin'):
def show_votes(votes):
today = date.today()
active_button = votes
- basequery = 'select *, roles.name as rolename from votes join roles on roles.id=votes.id_role'
+ basequery = 'select *, roles.name as rolename from votes join roles on roles.id=votes.id_role where open=1'
if votes == 'all':
votes = query_db(basequery + ' order by id desc')
elif votes == 'archive':
- votes = query_db(basequery + ' where date_end < (?) order by id desc', [today])
+ votes = query_db(basequery + ' and date_end < (?) order by id desc', [today])
elif votes == 'current':
- votes = query_db(basequery + ' where date_end >= (?) order by id desc', [today])
+ votes = query_db(basequery + ' and date_end >= (?) order by id desc', [today])
else:
abort(404)
return render_template('show_votes.html', votes=votes, active_button=active_button)
#-------------
# Votes admin
+@app.route('/votes/admin/list')
+def admin_votes():
+ if not session.get('user').get('is_admin'):
+ abort(401)
+ votes = query_db('select *, roles.name as rolename from votes join roles on roles.id=votes.id_role order by id desc')
+ return render_template('admin_votes.html', votes=votes)
+
@app.route('/votes/admin/add', methods=['GET', 'POST'])
def add_vote():
if not session.get('user').get('is_admin'):
--- /dev/null
+{% extends "layout.html" %}
+{% block subtitle %}Administrer les utilisateurs{% endblock %}
+{% block body %}
+<div class="row">
+ <hr />
+ {% if not users %}
+ <div class="alert">Il n'y a aucun user.</div>
+ {% else %}
+ <table class="table table-striped">
+ <thead>
+ <tr>
+ <th>E-mail</th>
+ <th>Nom</th>
+ <th>Groupes</th>
+ <th>Admin</th>
+ <th>Actions</th>
+ </tr>
+ </thead>
+ <tbody>
+ {% for user in users %}
+ <tr>
+ <td>{{ user.email }}</td>
+ <td>{{ user.name }}</td>
+ <td></td>
+ <td>{% if user.is_admin %}<span class="label label-success">Oui</span>{% else %}<span class="label">Non</span>{% endif %}</td>
+ <td>
+ <a href="" class="btn btn-mini">Éditer</a>
+ <a href="" class="btn btn-mini btn-danger">Supprimer</a>
+ </td>
+ </tr>
+ {% endfor %}
+ </tbody>
+ </table>
+ <p>
+ {% endif %}
+{% endblock %}
+
--- /dev/null
+{% extends "layout.html" %}
+{% block subtitle %}Administrer les votes{% endblock %}
+{% block body %}
+<div class="row">
+ <hr />
+ {% if not votes %}
+ <div class="alert">Il n'y a aucun vote.</div>
+ {% else %}
+ <table class="table table-striped">
+ <thead>
+ <tr>
+ <th>Nom</th>
+ <th>Statut</th>
+ <th>Deadline</th>
+ <th>Groupe</th>
+ <th>Catégorie</th>
+ <th>Options</th>
+ <th>Actions</th>
+ </tr>
+ </thead>
+ <tbody>
+ {% for vote in votes %}
+ <tr>
+ <td>{{ vote.title }}</td>
+ <td>{% if vote.is_open %}<span class="label label-success">Ouvert</span>{% else %}<span class="label label-important">Fermé</span>{% endif %}</td>
+ <td>{{ vote.date_end }}</td>
+ <td>{{ vote.rolename }}</td>
+ <td>{{ vote.category }}</td>
+ <td>
+ {% if vote.is_transparent %}<span class="label">transparent</span>{% endif %}
+ {% if vote.is_public %}<span class="label">public</span>{% endif %}
+ {% if vote.is_multiplechoice %}<span class="label">choix multiple</span>{% endif %}
+ </td>
+ <td><a href="{{ url_for('edit_vote', voteid=vote.id) }}" class="btn btn-mini">Éditer</a></td>
+ </tr>
+ {% endfor %}
+ </tbody>
+ </table>
+ <p>
+ <strong>Légende :</strong>
+ <ul class="unstyled">
+ <li><span class="label">transparent</span> : Les utilisateurs peuvent voir les votes des autres</li>
+ <li><span class="label">public</span> : Tout le monde peut voir le vote</li>
+ <li><span class="label">choix multiple</span> : Les utilisateurs peuvent effectuer plusieurs choix</li>
+ </ul>
+ </p>
+ {% endif %}
+{% endblock %}
+
<a href="#" class="btn btn-warning dropdown-toggle" data-toggle="dropdown">Admin <b class="caret"></b></a>
<ul class="dropdown-menu pull-right">
<li><a href="{{ url_for('add_vote') }}">Nouveau vote</a></li>
+ <li><a href="{{ url_for('admin_votes') }}">Administrer les votes</a></li>
<li class="divider"></li>
<!--<li><a href="404">Utilisateurs</a></li>-->
- <li><a href="{{ url_for('show_roles') }}">Groupes</a></li>
<li><a href="{{ url_for('add_user') }}">Nouvel utilisateur</a></li>
+ <li><a href="{{ url_for('admin_users') }}">Administrer les utilisateurs</a></li>
+ <li><a href="{{ url_for('show_roles') }}">Administrer les groupes</a></li>
</ul>
{% endif %}
</div>
{% extends "layout.html" %}
+{% block subtitle %}Administrer les votes{% endblock %}
{% block body %}
<div class="row">
<div class="span6 well">